<?php
define('KC_INDEX',True);
require_once '../global.php';
function king_def(){
	global $king;
	include_once('./library/Taoapi.php');
	include_once('./inc/fun.php');
	
		
		$tid=kc_get('category',0); 
		if(!empty($tid)){
		$tag=kc_get('tag','0');
		$cachepath="taobaoapi/lanmu";
		if(!$blockto=$king->cache->get($cachepath)){
		
			$a=taobao_itemcats_get($tid);
	
			$blockto[$tid]=$a[item_cats][item_cat];	
			$b=taobao_itemcats_get($a[item_cats][item_cat][parent_cid]);
			$blockto[$tid][sj]=$b[item_cats][item_cat];		

						if(empty($blockto[$tid])){//如果为空则写入缓存
							$king->cache->put($cachepath,$lanmu);
						}
		}			
	


		if($blockto[$tid]['parent_cid']=='50016687'){
			$str='孕妇';
		}


		echo '<h1>'.$str.str_replace(" ",$blockto[$tid][name].' '.$blockto[$tid][sj][name]."图片,".$str,$tag).$blockto[$tid][name].' '.$blockto[$tid][sj][name].'图片</h1>';
		}
		if(!empty($_GET[k])){
			$k=$_GET[k];

			$a=taobao_item_get($k);

			echo "<im>".$a[item][pic_url]."</im>";
			echo "<dh>".$a[item][num_iid]."</dh>";
			$titlek=keywords_class::k_dangdang_fc($a[item]['title'],'3');
			echo $titlek;




	require_once '../soso/class_ciji.php';/*必须的*/
	require_once '../soso/Snoopy.class.php';/*必须的*/
	$spider  = new spider();


	
	$url = urlencode(str_replace(',',' ',$titlek));

	$spider->kuiurl = "http://s.m.taobao.com/search.htm?_input_charset=utf-8&sst=1&atype=b&top_search=1&q=".$url;

	$spider->getContent();
	
	$spider->kuibody=array('地区的','<a name="search-again">');
	$arraly=array('#<a (.*)\">(.*)</a>#Us','yes');
	$kuibody=$spider->gettitle($arraly[0],$arraly[1]);//标题

	echo "<h1>";





		$cachepath="taobaoapi/chanshu";
		if(!$karray=$king->cache->get($cachepath)){
		
				$i=$king->db->getRows_one("select kcontent from %s_block where kname='内容采集关键词过滤'");	
				$karray['url']=explode('|',$i['kcontent']);
				$king->cache->put($cachepath,$karray);

		}		

	$logdata=$karray[url];




	foreach($kuibody[2] as $key => $val){
			$val=str_replace(' ','',$val);
			$val=str_replace("\n","",$val); 
			similar_text($val, $titlek, $percent[$val]);
			
			if($percent>40){
				foreach($logdata as $values){   
						if(strpos($val,$values)){ $vals.=$val.',';}
					}
				
			}
			
	}

	echo $vals."</h1>";

	if(!empty($vals)){
			$b=taobao_taobaoke_shops_convert($a[item][nick]);

			$d=kc_get('userid',0);
			if(empty($d)){
				$d=$b[taobaoke_shops][taobaoke_shop][user_id];
			}
			
			if($b[taobaoke_shops][taobaoke_shop][shop_type]=='B'){
					$instr = file_get_contents("http://rate.tmall.com/list_detail_rate.htm?itemId=".$k."&callback=k");
			}else{
					$instr = file_get_contents("http://rate.taobao.com/feedRateList.htm?userNumId=".$d."&auctionNumId=".$k."&currentPageNum=1&callback=k");
			
			}


			echo  mb_convert_encoding($instr,'UTF-8','GBK');
			
		}
		}
	

}



　
?>